package com.personal.dao;


import com.personal.domain.Individual;
import com.personal.util.partDisplay.IndividualPart;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface IndividualDao {

    
    @Select("select * from individualcustomer;")
    List<Individual> selectAll();


    @Select("select id,customerName,customerCode,attributionRange,mainDockingMan,mainDockingManPhone,underRent from individualcustomer")
    List<IndividualPart> selectPartAll();

    @Select("select id,customerName,customerCode,attributionRange,mainDockingMan,mainDockingManPhone,underRent from individualcustomer " +
            "where customerName like CONCAT('%',#{name},'%') and customerCode like CONCAT('%',#{code},'%')")
    List<IndividualPart> selectPartByKey(String name,String code);


    @Select("insert into individualcustomer (id, affiliatedProject, customerName, customerAbbreviation, customerType, customerCode," +
            "                                        documentType, documentCode, customerPhone, occupation, sex, dateOfBirth, nationality," +
            "                                        email, emergencyContact, emergencyContactPhone, residentialAddress, incubatedEnterprise," +
            "                                        attributionRange, mainDockingMan, mainDockingManPhone, customerServiceManager," +
            "                                        customerServiceManagerPhone, financialCustomerCode, compoundInterest, underRent," +
            "                                        compoundInterestRules, fourEnterprises, highTechEnterprise, blacklist, remark, attachments" +
            "                                        ) VALUE" +
            "                                        (null,#{affiliatedProject},#{customerName},#{customerAbbreviation},#{customerType},#{customerCode}," +
            "                                        #{documentType},#{documentCode},#{customerPhone},#{occupation},#{sex},#{dateOfBirth},#{nationality}," +
            "                                        #{email},#{emergencyContact},#{emergencyContactPhone},#{residentialAddress},#{incubatedEnterprise}," +
            "                                        #{attributionRange},#{mainDockingMan},#{mainDockingManPhone},#{customerServiceManager}," +
            "                                        #{customerServiceManagerPhone},#{financialCustomerCode},#{compoundInterest},#{underRent}," +
            "                                        #{compoundInterestRules},#{fourEnterprises},#{highTechEnterprise},#{blacklist},#{remark},#{attachments})")
    int add(Individual individual);
    
    @Select("select * from individualcustomer where id=#{id}")
    Individual getUpdate(int id);
    @Update("update individualcustomer set affiliatedProject=#{affiliatedProject}, customerName=#{customerName}, customerAbbreviation=#{customerAbbreviation}," +
            "                                      customerType=#{customerType}, customerCode=#{customerCode}," +
            "                                      documentType=#{documentType}, documentCode=#{documentCode}, customerPhone=#{customerPhone}," +
            "                                      occupation=#{occupation}, sex=#{sex}, dateOfBirth=#{dateOfBirth}, nationality=#{nationality}," +
            "                                      email=#{email}, emergencyContact=#{emergencyContact}, emergencyContactPhone=#{emergencyContactPhone}," +
            "                                      residentialAddress=#{residentialAddress}, incubatedEnterprise=#{incubatedEnterprise}," +
            "                                      attributionRange=#{attributionRange}, mainDockingMan=#{mainDockingMan}, mainDockingManPhone=#{mainDockingManPhone}," +
            "                                      customerServiceManager=#{customerServiceManager},customerServiceManagerPhone=#{customerServiceManagerPhone}," +
            "                                      financialCustomerCode=#{financialCustomerCode}, compoundInterest=#{compoundInterest}, underRent=#{underRent}," +
            "                                      compoundInterestRules=#{compoundInterestRules}, fourEnterprises=#{fourEnterprises}, highTechEnterprise=#{highTechEnterprise}," +
            "                                      blacklist=#{blacklist}, remark=#{remark}, attachments=#{attachments} where id=#{id}")
    int update(Individual individual);

    @Delete("delete from individualcustomer where id=#{id}")
    int delete(int id);





}
